<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix = "c"  uri = "http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML>
<html lang="en-US">
<head>
	<meta charset="UTF-8">
	<link rel="stylesheet" type="text/css"  href="css/bootstrap.min.css"/>
	<title>凯胜项目管理系统</title>
	<style type="text/css">
		body{
			padding-top:70px;
		}
	</style>
</head>
<body class="body">
	<%@include file="same2.jsp" %>
	
	<div class="container">
		<div class="row">
			<%@include file="same.jsp" %>
			<div class="span9" >
				<div class="clear"></div>
				<form id = "toedit" class="form-horizontal" method = "post" action = "contact.jspx?method=edit&id=${param.id }">
						<fieldset>
						<legend>编辑联系人→${editcontact.name }</legend>
						<div class="control-group">
							<label class="control-label" for="input01">姓名</label>
							<div class="controls">
								<input name = "name" type="text" class="span5" id="name" value = "${editcontact.name }"><span style = "color:red" id = "tname"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">公司</label>
							<div class="controls">
								<input name = "company" type="text" class="span5" id="mycom" value = "${editcontact.company}"><span style = "color:red" id ="tmycompany"></span>
							</div>
						</div>
						<hr>
						<div class="control-group">
							<label class="control-label" for="input01">手机</label>
							<div class="controls">
								<input name = "cellphone" type="text" class="span5" id="cellphone" value = "${editcontact.cellphone}"}><span style = "color:red" id = "tcellphone"></span>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">固话</label>
							<div class="controls">
								<input type="text" name = "telphone" class="span5" id="telphone" value = "${editcontact.telphone}">
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01" }>邮箱</label>
							<div class="controls" >
								<input name = "email" type="text" class="span5" id="email" value = "${editcontact.email}"><span style = "color:red" id = "temail"></span>
							</div>
						</div>
						<hr>
						<div class="control-group">
							<label class="control-label" for="input01">地址</label>
							<div class="controls">
								<input name = "address" type="text" class="span5" id="address" value = "${editcontact.address}"><span style = "color:red" id = "taddress"></span>
							</div>
						</div>
						<hr>
						<div class="control-group">
							<label class="control-label" for="input01">主页</label>
							<div class="controls">
								<input type="text" class="span5" id="mainpage" value = "${editcontact.mainpage}" name = "mainpage" >
								<p class="help-block">http://www.xxx.com</p>
							</div>
						</div>
						<div class="control-group">
							<label class="control-label" for="input01">微博</label>
							<div class="controls">
								<select name="url">
								<c:choose>
									<c:when test="${editcontact.prexweb=='http://sina.com/'}">
										<option value = "http://web.com/">新浪微博</option>
										<option value = "http://t.qq.com/">腾讯微博 </option>
										<option value = "http://twritter.com/">Twritter</option>
									</c:when>
									<c:when test="${editcontact.prexweb == 'http://qq.com/'}">
										<option value = "http://t.qq.com/">腾讯微博 </option>
										<option value = "http://web.com/">新浪微博</option>
										
										<option value = "http://twritter.com/">Twritter</option>
									</c:when>
									<c:when test="${editcontact.prexweb == 'http://twritter.com/'}">
										<option value = "http://twritter.com/">Twritter</option>
										<option value = "http://web.com/">新浪微博</option>
										<option value = "http://t.qq.com/">腾讯微博 </option>
									</c:when>
									<c:otherwise>
										<option>选择</option>
										<option value = "https://sina.com/">新浪微博</option>
										<option value = "https://qq.com/">腾讯微博 </option>
										<option value = "https://twritter.com/">Twritter</option>
										
									</c:otherwise>
	
								</c:choose>
									
							  </select>
							  <div class="input-prepend">
							 <span class="add-on">@</span><input name = "web"class="span2 myweb" id="prependedInput" size="16" type="text" x-webkit-speech="undefined" value = "${editcontact.web}" ></label>
							 </div>
						  </div>
						 </div> 
						<div class="control-group">
							<label class="control-label" for="input01">简介</label>
							<div class="controls">
								<textarea   class="span5"  id="input01" rows="6" name = "introduce">${editcontact.introduce}</textarea>
							</div>
						</div>
						<div class="form-actions">
							<button type="button" id = "save" class="btn btn-primary">保存</button>
							<a  href = "contact.jspx"class = "btn"> 返回</a>
					  </div>
						</fieldset>
					</form>
				
			</div>
	</div>
</div>	
	<script type="text/javascript" src="js/jquery.js"></script>
	<script type="text/javascript" src="js/bootstrap.min.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#myid li").eq(6).addClass("active");
			$("#myid i").eq(4).addClass("icon-white");
			$("#name").blur(function(){
				var name = $("#name").val();
				if(name.trim().length == 0){
					$("#tname").html("*不能为空");
				}
			});
			$("#email").blur(function(){
				var name = $("#email").val();
				var str = /^\w+@\w+(\.\w+){1,2}$/;
				if(!str.test(name)){
					$("#temail").html("格式不正确");
				}
			});
			
			$("#email").keyup(function(){
				$("#temail").html("");
			
			});
			$("#name").keyup(function(){
				$("#tname").html("");
			
			});
			$("#mycom").blur(function(){
				var name = $("#mycom").val();
				if(name.trim().length == 0){
					$("#tmycompany").html("*不能为空");
				}
			});
			$("#mycom").keyup(function(){
				$("#tmycompany").html("");
			
			});
			$("#cellphone").keyup(function(){
				$("#tcellphone").html("");
			
			});
			$("#address").keyup(function(){
				$("#taddress").html("");
			
			});
			
			$("#cellphone").blur(function(){
				var name = $("#cellphone").val();
				if(name.trim().length == 0){
					$("#tcellphone").html("*不能为空");
				}else {
					var reg = /^1[4|5|3|8]\d{9}$/;
					if(reg.test(name)){
						return true;
					
					}else{
						$("#tcellphone").html("格式不正确");
					
					}
				
				}
			
			
			});
			$("#address").blur(function(){
			
				var name = $("#address").val();
				if(name.trim().length == 0){
					$("#taddress").html("*不能为空");
				}
			});
			$("#save").click(function(){
			
				var name = $("#name").val();
				if(name.trim().length == 0){
					$("#tname").html("*不能为空");
					return;
				}
				
				
				var name2 = $("#mycom").val();
				if(name2.trim().length == 0){
					$("#tmycompany").html("*不能为空");
					return
				}
				
				
				var name3 = $("#cellphone").val();
				if(name3.trim().length == 0){
					$("#tcellphone").html("*不能为空");
					return;
				}else {
					var reg = /^1[4|5|3|8]\d{9}$/;
					if(!reg.test(name3)){
						$("#tcellphone").html("格式不正确");
						return;
					
					}
				
				}
			
			
		
				var name4 = $("#address").val();
				if(name4.trim().length == 0){
					$("#taddress").html("*不能为空");
					return;
				}
			
			
				var name5 = $("#email").val();
				var str = /^\w+@\w+(\.\w+){1,2}$/;
				if(!str.test(name5)){
					$("#temail").html("格式不正确");
					return;
				}
				
				$("#toedit").submit();
		});
		});
		
	</script>
</body>
</html>
